package com.sihai.ehr.web.action.ajax;

import com.sihai.core.LimitedList;
import com.sihai.core.beans.BeanInject;
import com.sihai.ehr.model.biz.AuditType;
import com.sihai.ehr.model.biz.ContractVersion;
import com.sihai.ehr.model.sys.AuditStatus;
import com.sihai.ehr.model.sys.Organization;
import com.sihai.ehr.service.ContractService;
import com.sihai.ehr.web.action.EHRAction;
import org.apache.commons.lang.xwork.StringUtils;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;

/**
 * @author: wxn
 * @since: 12-6-22 下午17:48
 *
 * 合同相关 ajax action
 */

public class ContractAction extends EHRAction{

    @BeanInject
    private ContractService contractService;

    private LimitedList<ContractVersion> versions;

    @Action(value = "/ajax/contact-version-list", results = {
            @Result(name = "success", type = "json", params = {"root", "versions"})
    })
    @Override
    public String execute() throws Exception {
        if(organizationId != null){
            versions = contractService.findVersionsByOrganizationId(organizationId, null, createSorter());
        }

        return SUCCESS;
    }

    public LimitedList<ContractVersion> getVersions() {
        return versions;
    }

    public void setVersions(LimitedList<ContractVersion> versions) {
        this.versions = versions;
    }
}